package com.bckj.fastboot.flow.model;

import com.bckj.fastboot.flow.process.BpmnVisitor;
import lombok.Data;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public abstract class BpmnElement {

    public static final String PROP_PARALLEL_PATH = "ParallelPath";

    private final String id;
    private final String name;
    private final String type;
    // 存储元素的入边
    List<BpmnSequenceFlow> incomingFlows = new ArrayList<>();
    // 存储元素的出边
    List<BpmnSequenceFlow> outgoingFlows = new ArrayList<>();
    //属性
    Map<String, Object> properties = new HashMap<>();

    public BpmnElement(String id, String name, String type) {
        this.id = id;
        this.name = name;
        this.type = type;
    }

    public void addIncomingFlow(BpmnSequenceFlow flow) {
        incomingFlows.add(flow);
    }

    public void addOutgoingFlow(BpmnSequenceFlow flow) {
        outgoingFlows.add(flow);
    }

    public void addProperty(String key, Object value) {
        properties.put(key, value);
    }

    public Object getProperty(String key) {
        return properties.get(key);
    }

    public abstract void accept(BpmnVisitor visitor);
}